;; -*- coding: utf-8 -*-
;;----------------------------------------------------------------------------
;; Suppress GUI features
;;----------------------------------------------------------------------------
(setq use-file-dialog nil)
(setq use-dialog-box nil)
(setq inhibit-startup-screen t)
(setq inhibit-startup-echo-area-message t)


;;----------------------------------------------------------------------------
;; Show a marker in the left fringe for lines not in the buffer
;;----------------------------------------------------------------------------
(setq indicate-empty-lines t)


;;----------------------------------------------------------------------------
;; Window size and features
;;----------------------------------------------------------------------------
(defun adjust-opacity (frame incr)
  (let* ((oldalpha (or (frame-parameter frame 'alpha) 100))
         (newalpha (+ incr oldalpha)))
    (when (and (<= frame-alpha-lower-limit newalpha) (>= 100 newalpha))
      (modify-frame-parameters frame (list (cons 'alpha newalpha))))))

(setq is-fs nil)
(when (string= window-system "w32")
  (defun ns-toggle-fullscreen ()
    (interactive)
      (cond
       (is-fs (progn (w32-send-sys-command #xF120) (setq is-fs nil)))
       (t (progn (w32-send-sys-command #xF030) (setq is-fs t)))))
    
    ;; Command-Option-f to toggle fullscreen mode
    (global-set-key [f11] 'ns-toggle-fullscreen))

(global-set-key (kbd "M-C--") '(lambda () (interactive) (adjust-opacity nil -5)))
(global-set-key (kbd "M-C-=") '(lambda () (interactive) (adjust-opacity nil 5)))
(global-set-key (kbd "M-C-0") '(lambda () (interactive) (modify-frame-parameters nil `((alpha . 100)))))

(add-hook 'after-make-frame-functions
          (lambda (frame)
            (with-selected-frame frame
              (unless window-system
                (set-frame-parameter nil 'menu-bar-lines nil)))))

;; 新的frame也使用自定义的字体和默认大小
(require 'init-fonts)
(add-to-list 'default-frame-alist '(height . 35))
(add-to-list 'default-frame-alist '(width . 125))
(add-to-list 'default-frame-alist '(font . "fontset-myfontset"))


(provide 'init-gui-frames)
